package com.jumi.microservice.stock.controller;

import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.stock.dto.StockGoodsRequest;
import com.jumi.microservice.stock.dto.StockGoodsResponse;
import com.jumi.microservice.stock.service.StockGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName StockController
 * @Description
 * @Author Abel Yang
 * @Date 2020/8/19/019 14:50
 **/
@RestController
@RequestMapping("/supply/stock/goods")
@Api(tags = {"【仓库管理】库存管理接口"})
public class StockGoodsController extends BaseController {

    @Resource
    private StockGoodsService stockGoodsService;

    /**
     * @Description: 查询商品库存列表
     * @Param stockGoodsRequest
     * @Return {@link TableDataInfo<  StockGoodsResponse >}
     * @Throws
     * @Author Abel Yang
     * @Date 2020/8/22/022 14:26
     * @return
     */
    @PostMapping("/getListByPage")
    @ApiOperation("分页查询商品库存分页列表")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "goodsId", value = "商品id", dataType = "Long", paramType = "query"),
                    @ApiImplicitParam(name = "goodsCode", value = "商品编码", dataType = "String", paramType = "query"),
                    @ApiImplicitParam(name = "goodsName", value = "商品名称", dataType = "String", paramType = "query"),
                    @ApiImplicitParam(name = "goodsType", value = "商品类型", dataType = "Byte", allowableValues = "0,1", paramType = "query"),
                    @ApiImplicitParam(name = "status", value = "商品状态", dataType = "Byte", allowableValues = "0,1", paramType = "query"),
                    @ApiImplicitParam(name = "alarmed", value = "是否预警", dataType = "Boolean", paramType = "query"),
                    @ApiImplicitParam(name = "supplierId", value = "供应商id", dataType = "Long", paramType = "query"),
                    @ApiImplicitParam(name = "warehouseId", value = "仓库id", dataType = "Long", defaultValue = "0", paramType = "query"),
            })
    public TableDataInfo<List<StockGoodsResponse>> getStockGoodsListByPage(StockGoodsRequest stockGoodsRequest) {
        startPage();
        List<StockGoodsResponse> stockGoodsList = stockGoodsService.getStockGoodsList(stockGoodsRequest);
        return getDataTable(stockGoodsList);
    }
}
